{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 导入模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/root/miniconda3/bin/python'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys\n",
    "\n",
    "sys.executable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from os import path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import gc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1.Trajectory tracking.ipynb',\n",
       " 'Question recored.md',\n",
       " 'data_eda.ipynb',\n",
       " '.ipynb_checkpoints',\n",
       " '1.Trajectory tracking-checkpoint.ipynb',\n",
       " '未命名.ipynb']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 用户轨迹探索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('20190524-001.csv', nrows=1000, encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>imsi_</th>\n",
       "      <th>imei_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th>lac_</th>\n",
       "      <th>cellid_</th>\n",
       "      <th>status_</th>\n",
       "      <th>ap_type_</th>\n",
       "      <th>device_id_</th>\n",
       "      <th>eventid_</th>\n",
       "      <th>area_</th>\n",
       "      <th>msisdn_</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>460110413044304</td>\n",
       "      <td>\\t</td>\n",
       "      <td>2019-05-08 20:09:29\\t</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝\\t</td>\n",
       "      <td>FDD-LTE\\t</td>\n",
       "      <td>DX-SZSC001\\t</td>\n",
       "      <td>Normal Lau\\t</td>\n",
       "      <td>\\t</td>\n",
       "      <td>\\t</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>460110413042577</td>\n",
       "      <td>\\t</td>\n",
       "      <td>2019-05-08 20:09:41\\t</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝\\t</td>\n",
       "      <td>FDD-LTE\\t</td>\n",
       "      <td>DX-SZSC001\\t</td>\n",
       "      <td>Normal Lau\\t</td>\n",
       "      <td>\\t</td>\n",
       "      <td>\\t</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>460110425023300</td>\n",
       "      <td>\\t</td>\n",
       "      <td>2019-05-08 20:10:14\\t</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝\\t</td>\n",
       "      <td>FDD-LTE\\t</td>\n",
       "      <td>DX-SZSC001\\t</td>\n",
       "      <td>Normal Lau\\t</td>\n",
       "      <td>\\t</td>\n",
       "      <td>\\t</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>460110714141865</td>\n",
       "      <td>\\t</td>\n",
       "      <td>2019-05-08 20:10:40\\t</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝\\t</td>\n",
       "      <td>FDD-LTE\\t</td>\n",
       "      <td>DX-SZSC001\\t</td>\n",
       "      <td>Normal Lau\\t</td>\n",
       "      <td>\\t</td>\n",
       "      <td>\\t</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>460016692088409</td>\n",
       "      <td>\\t</td>\n",
       "      <td>2019-05-08 20:08:55\\t</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝\\t</td>\n",
       "      <td>FDD-LTE\\t</td>\n",
       "      <td>LT-SZSC001\\t</td>\n",
       "      <td>Normal Lau\\t</td>\n",
       "      <td>\\t</td>\n",
       "      <td>\\t</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             imsi_ imei_           update_time_  lac_  cellid_ status_  \\\n",
       "0  460110413044304    \\t  2019-05-08 20:09:29\\t     0        0    拒绝\\t   \n",
       "1  460110413042577    \\t  2019-05-08 20:09:41\\t     0        0    拒绝\\t   \n",
       "2  460110425023300    \\t  2019-05-08 20:10:14\\t     0        0    拒绝\\t   \n",
       "3  460110714141865    \\t  2019-05-08 20:10:40\\t     0        0    拒绝\\t   \n",
       "4  460016692088409    \\t  2019-05-08 20:08:55\\t     0        0    拒绝\\t   \n",
       "\n",
       "    ap_type_    device_id_      eventid_ area_ msisdn_  \n",
       "0  FDD-LTE\\t  DX-SZSC001\\t  Normal Lau\\t    \\t      \\t  \n",
       "1  FDD-LTE\\t  DX-SZSC001\\t  Normal Lau\\t    \\t      \\t  \n",
       "2  FDD-LTE\\t  DX-SZSC001\\t  Normal Lau\\t    \\t      \\t  \n",
       "3  FDD-LTE\\t  DX-SZSC001\\t  Normal Lau\\t    \\t      \\t  \n",
       "4  FDD-LTE\\t  LT-SZSC001\\t  Normal Lau\\t    \\t      \\t  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "drop_col = ['imei_', 'area_', 'msisdn_']\n",
    "data1 = data.drop(drop_col,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_data(file_name):\n",
    "    file_extension = path.splitext(file_name)[1]\n",
    "    if file_extension == '.csv':\n",
    "        data = pd.read_csv(file_name, encoding='gbk')\n",
    "    elif file_extension == '.xlsx':\n",
    "        data = pd.read_excel(file_name, encoding='gbk')\n",
    "    drop_col = ['imei_', 'area_', 'msisdn_']\n",
    "    data.drop(drop_col, axis=1, inplace=True)\n",
    "    col = data.columns\n",
    "    for each in col:\n",
    "        if data[each].dtype == object:\n",
    "            data[each] = data[each].str.replace('\\t', '')\n",
    "    print('data processed successfully')\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['4月',\n",
       " '20190529',\n",
       " '20190529-4G电围.xls',\n",
       " '.DS_Store',\n",
       " '分析数据',\n",
       " '3月',\n",
       " 'data_eda.ipynb',\n",
       " 'same',\n",
       " '.ipynb_checkpoints',\n",
       " '20190529-001.csv',\n",
       " '20190424-001.xlsx',\n",
       " '20190524-001.csv',\n",
       " '20190529-4G_resave.csv',\n",
       " 'test.py',\n",
       " '20190422-灵瞳感知器.xls',\n",
       " '最新数据',\n",
       " '050823数据表']"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "data processed successfully\n",
      "data processed successfully\n"
     ]
    }
   ],
   "source": [
    "data1 = get_data('20190524-001.csv')\n",
    "data2 = get_data('20190529-001.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th>lac_</th>\n",
       "      <th>cellid_</th>\n",
       "      <th>status_</th>\n",
       "      <th>ap_type_</th>\n",
       "      <th>device_id_</th>\n",
       "      <th>eventid_</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>460110413044304</td>\n",
       "      <td>2019-05-08 20:09:29</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>460110413042577</td>\n",
       "      <td>2019-05-08 20:09:41</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>460110425023300</td>\n",
       "      <td>2019-05-08 20:10:14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>460110714141865</td>\n",
       "      <td>2019-05-08 20:10:40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>460016692088409</td>\n",
       "      <td>2019-05-08 20:08:55</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>LT-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             imsi_         update_time_  lac_  cellid_ status_ ap_type_  \\\n",
       "0  460110413044304  2019-05-08 20:09:29     0        0      拒绝  FDD-LTE   \n",
       "1  460110413042577  2019-05-08 20:09:41     0        0      拒绝  FDD-LTE   \n",
       "2  460110425023300  2019-05-08 20:10:14     0        0      拒绝  FDD-LTE   \n",
       "3  460110714141865  2019-05-08 20:10:40     0        0      拒绝  FDD-LTE   \n",
       "4  460016692088409  2019-05-08 20:08:55     0        0      拒绝  FDD-LTE   \n",
       "\n",
       "   device_id_    eventid_  \n",
       "0  DX-SZSC001  Normal Lau  \n",
       "1  DX-SZSC001  Normal Lau  \n",
       "2  DX-SZSC001  Normal Lau  \n",
       "3  DX-SZSC001  Normal Lau  \n",
       "4  LT-SZSC001  Normal Lau  "
      ]
     },
     "execution_count": 158,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [],
   "source": [
    "def convert_to_time(data):\n",
    "    for each in data:\n",
    "#         print(each.columns)\n",
    "        each.index = pd.to_datetime(each['update_time_'])\n",
    "#         print(each.colums)\n",
    "#         each.drop(['update_time_'], axis=1, inplace=True)\n",
    "    print('successfully')\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "successfully\n"
     ]
    }
   ],
   "source": [
    "data1_, data2_ = convert_to_time([data1, data2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th>lac_</th>\n",
       "      <th>cellid_</th>\n",
       "      <th>status_</th>\n",
       "      <th>ap_type_</th>\n",
       "      <th>device_id_</th>\n",
       "      <th>eventid_</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>update_time_</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:09:29</th>\n",
       "      <td>460110413044304</td>\n",
       "      <td>2019-05-08 20:09:29</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:09:41</th>\n",
       "      <td>460110413042577</td>\n",
       "      <td>2019-05-08 20:09:41</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:10:14</th>\n",
       "      <td>460110425023300</td>\n",
       "      <td>2019-05-08 20:10:14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:10:40</th>\n",
       "      <td>460110714141865</td>\n",
       "      <td>2019-05-08 20:10:40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:08:55</th>\n",
       "      <td>460016692088409</td>\n",
       "      <td>2019-05-08 20:08:55</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>LT-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               imsi_         update_time_  lac_  cellid_  \\\n",
       "update_time_                                                               \n",
       "2019-05-08 20:09:29  460110413044304  2019-05-08 20:09:29     0        0   \n",
       "2019-05-08 20:09:41  460110413042577  2019-05-08 20:09:41     0        0   \n",
       "2019-05-08 20:10:14  460110425023300  2019-05-08 20:10:14     0        0   \n",
       "2019-05-08 20:10:40  460110714141865  2019-05-08 20:10:40     0        0   \n",
       "2019-05-08 20:08:55  460016692088409  2019-05-08 20:08:55     0        0   \n",
       "\n",
       "                    status_ ap_type_  device_id_    eventid_  \n",
       "update_time_                                                  \n",
       "2019-05-08 20:09:29      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:09:41      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:10:14      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:10:40      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:08:55      拒绝  FDD-LTE  LT-SZSC001  Normal Lau  "
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(338898, 8)"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(430480, 8)"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以发现，数据1检测的时间有16天。数据2检测的时间有7天"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1_.index.day[-1] - data1_.index.day[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "21"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2_.index.day[-1] - data2_.index.day[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "update_time_\n",
       "2019-05-08 20:09:29    460110413044304\n",
       "2019-05-08 20:09:41    460110413042577\n",
       "2019-05-08 20:10:14    460110425023300\n",
       "2019-05-08 20:10:40    460110714141865\n",
       "2019-05-08 20:08:55    460016692088409\n",
       "                            ...       \n",
       "2019-05-15 23:58:43    460019454206454\n",
       "2019-05-15 23:59:11    460015232357562\n",
       "2019-05-15 23:59:21    460008760270567\n",
       "2019-05-15 23:59:24    460110714141865\n",
       "2019-05-15 23:59:46    460029420804175\n",
       "Name: imsi_, Length: 147072, dtype: int64"
      ]
     },
     "execution_count": 149,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 可以按时间这样切片。但必须是Series，不能是DF\n",
    "data1_.imsi_['20190508':'20190515']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {},
   "outputs": [],
   "source": [
    "one_week = data1_.loc['20190508':'20190515', :]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th>lac_</th>\n",
       "      <th>cellid_</th>\n",
       "      <th>status_</th>\n",
       "      <th>ap_type_</th>\n",
       "      <th>device_id_</th>\n",
       "      <th>eventid_</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>update_time_</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:09:29</th>\n",
       "      <td>460110413044304</td>\n",
       "      <td>2019-05-08 20:09:29</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:09:41</th>\n",
       "      <td>460110413042577</td>\n",
       "      <td>2019-05-08 20:09:41</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:10:14</th>\n",
       "      <td>460110425023300</td>\n",
       "      <td>2019-05-08 20:10:14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:10:40</th>\n",
       "      <td>460110714141865</td>\n",
       "      <td>2019-05-08 20:10:40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-08 20:08:55</th>\n",
       "      <td>460016692088409</td>\n",
       "      <td>2019-05-08 20:08:55</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>LT-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               imsi_         update_time_  lac_  cellid_  \\\n",
       "update_time_                                                               \n",
       "2019-05-08 20:09:29  460110413044304  2019-05-08 20:09:29     0        0   \n",
       "2019-05-08 20:09:41  460110413042577  2019-05-08 20:09:41     0        0   \n",
       "2019-05-08 20:10:14  460110425023300  2019-05-08 20:10:14     0        0   \n",
       "2019-05-08 20:10:40  460110714141865  2019-05-08 20:10:40     0        0   \n",
       "2019-05-08 20:08:55  460016692088409  2019-05-08 20:08:55     0        0   \n",
       "\n",
       "                    status_ ap_type_  device_id_    eventid_  \n",
       "update_time_                                                  \n",
       "2019-05-08 20:09:29      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:09:41      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:10:14      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:10:40      拒绝  FDD-LTE  DX-SZSC001  Normal Lau  \n",
       "2019-05-08 20:08:55      拒绝  FDD-LTE  LT-SZSC001  Normal Lau  "
      ]
     },
     "execution_count": 151,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "one_week.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.31764713881636203"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "one_week.imsi_.nunique()/one_week.shape[0] # 说明大部分id都是重复出现过的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['DX-SZSC001', 'LT-SZSC001', 'YD-SZSC001'], dtype=object)"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 说明只有三个机器\n",
    "one_week.device_id_.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Normal Lau'], dtype=object)"
      ]
     },
     "execution_count": 154,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "one_week.eventid_.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "460110714141865    1732\n",
       "460110413044304     581\n",
       "460012480316441     515\n",
       "460110700163772     479\n",
       "460014946660039     457\n",
       "                   ... \n",
       "460002606630392       1\n",
       "460002606768993       1\n",
       "460022786534869       1\n",
       "460075737808351       1\n",
       "460028146282347       1\n",
       "Name: imsi_, Length: 46717, dtype: int64"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "one_week.imsi_.value_counts() # 有很多一个星期只出现过一次的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = data1.groupby(['imsi_', 'update_time_',])['device_id_'].value_counts().unstack()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "117"
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "imsi_            device_id_  update_time_       \n",
       "204043315383882  DX-SZSC001  2019-05-23 17:20:10    1\n",
       "204043863737390  DX-SZSC001  2019-05-24 14:51:06    1\n",
       "204046031010732  DX-SZSC001  2019-05-09 14:19:45    1\n",
       "204047102616026  LT-SZSC001  2019-05-15 20:13:18    1\n",
       "206012229081504  YD-SZSC001  2019-05-10 12:11:12    1\n",
       "                                                   ..\n",
       "525058231350753  YD-SZSC001  2019-05-10 13:44:48    1\n",
       "                             2019-05-10 14:01:04    1\n",
       "                             2019-05-10 14:16:48    1\n",
       "                             2019-05-10 14:32:55    1\n",
       "641101902316484  YD-SZSC001  2019-05-17 22:42:52    1\n",
       "Name: update_time_, Length: 338796, dtype: int64"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data1.groupby(['imsi_', 'device_id_',])['update_time_'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>device_id_</th>\n",
       "      <th>DX-SZSC001</th>\n",
       "      <th>LT-SZSC001</th>\n",
       "      <th>YD-SZSC001</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>204043315383882</th>\n",
       "      <th>2019-05-23 17:20:10</th>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204043863737390</th>\n",
       "      <th>2019-05-24 14:51:06</th>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204046031010732</th>\n",
       "      <th>2019-05-09 14:19:45</th>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204047102616026</th>\n",
       "      <th>2019-05-15 20:13:18</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>206012229081504</th>\n",
       "      <th>2019-05-10 12:11:12</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "device_id_                           DX-SZSC001  LT-SZSC001  YD-SZSC001\n",
       "imsi_           update_time_                                           \n",
       "204043315383882 2019-05-23 17:20:10         1.0         NaN         NaN\n",
       "204043863737390 2019-05-24 14:51:06         1.0         NaN         NaN\n",
       "204046031010732 2019-05-09 14:19:45         1.0         NaN         NaN\n",
       "204047102616026 2019-05-15 20:13:18         NaN         1.0         NaN\n",
       "206012229081504 2019-05-10 12:11:12         NaN         NaN         1.0"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(338796, 3)"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['DX-SZSC001', 'LT-SZSC001', 'YD-SZSC001'], dtype='object', name='device_id_')"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(204043315383882, '2019-05-23 17:20:10')"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.index[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**可以发现res的columns只有三列。而index是元祖的形式**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = res.fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>device_id_</th>\n",
       "      <th>DX-SZSC001</th>\n",
       "      <th>LT-SZSC001</th>\n",
       "      <th>YD-SZSC001</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>204043315383882</th>\n",
       "      <th>2019-05-23 17:20:10</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204043863737390</th>\n",
       "      <th>2019-05-24 14:51:06</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204046031010732</th>\n",
       "      <th>2019-05-09 14:19:45</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204047102616026</th>\n",
       "      <th>2019-05-15 20:13:18</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>206012229081504</th>\n",
       "      <th>2019-05-10 12:11:12</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">525058231350753</th>\n",
       "      <th>2019-05-10 13:44:48</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-10 14:01:04</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-10 14:16:48</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-05-10 14:32:55</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>641101902316484</th>\n",
       "      <th>2019-05-17 22:42:52</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>338796 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "device_id_                           DX-SZSC001  LT-SZSC001  YD-SZSC001\n",
       "imsi_           update_time_                                           \n",
       "204043315383882 2019-05-23 17:20:10         1.0         0.0         0.0\n",
       "204043863737390 2019-05-24 14:51:06         1.0         0.0         0.0\n",
       "204046031010732 2019-05-09 14:19:45         1.0         0.0         0.0\n",
       "204047102616026 2019-05-15 20:13:18         0.0         1.0         0.0\n",
       "206012229081504 2019-05-10 12:11:12         0.0         0.0         1.0\n",
       "...                                         ...         ...         ...\n",
       "525058231350753 2019-05-10 13:44:48         0.0         0.0         1.0\n",
       "                2019-05-10 14:01:04         0.0         0.0         1.0\n",
       "                2019-05-10 14:16:48         0.0         0.0         1.0\n",
       "                2019-05-10 14:32:55         0.0         0.0         1.0\n",
       "641101902316484 2019-05-17 22:42:52         0.0         0.0         1.0\n",
       "\n",
       "[338796 rows x 3 columns]"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function unstack in module pandas.core.frame:\n",
      "\n",
      "unstack(self, level=-1, fill_value=None)\n",
      "    Pivot a level of the (necessarily hierarchical) index labels.\n",
      "    \n",
      "    Returns a DataFrame having a new level of column labels whose inner-most level\n",
      "    consists of the pivoted index labels.\n",
      "    \n",
      "    If the index is not a MultiIndex, the output will be a Series\n",
      "    (the analogue of stack when the columns are not a MultiIndex).\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    level : int, str, or list of these, default -1 (last level)\n",
      "        Level(s) of index to unstack, can pass level name.\n",
      "    fill_value : int, str or dict\n",
      "        Replace NaN with this value if the unstack produces missing values.\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    Series or DataFrame\n",
      "    \n",
      "    See Also\n",
      "    --------\n",
      "    DataFrame.pivot : Pivot a table based on column values.\n",
      "    DataFrame.stack : Pivot a level of the column labels (inverse operation\n",
      "        from `unstack`).\n",
      "    \n",
      "    Examples\n",
      "    --------\n",
      "    >>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),\n",
      "    ...                                    ('two', 'a'), ('two', 'b')])\n",
      "    >>> s = pd.Series(np.arange(1.0, 5.0), index=index)\n",
      "    >>> s\n",
      "    one  a   1.0\n",
      "         b   2.0\n",
      "    two  a   3.0\n",
      "         b   4.0\n",
      "    dtype: float64\n",
      "    \n",
      "    >>> s.unstack(level=-1)\n",
      "         a   b\n",
      "    one  1.0  2.0\n",
      "    two  3.0  4.0\n",
      "    \n",
      "    >>> s.unstack(level=0)\n",
      "       one  two\n",
      "    a  1.0   3.0\n",
      "    b  2.0   4.0\n",
      "    \n",
      "    >>> df = s.unstack(level=0)\n",
      "    >>> df.unstack()\n",
      "    one  a  1.0\n",
      "         b  2.0\n",
      "    two  a  3.0\n",
      "         b  4.0\n",
      "    dtype: float64\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(pd.DataFrame.unstack)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [],
   "source": [
    "def trace(data):\n",
    "    data1.groupby(['imsi_', 'update_time_',])['device_id_'].value_counts().unstack(fill_vause=0)\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>imsi_</th>\n",
       "      <th>update_time_</th>\n",
       "      <th>lac_</th>\n",
       "      <th>cellid_</th>\n",
       "      <th>status_</th>\n",
       "      <th>ap_type_</th>\n",
       "      <th>device_id_</th>\n",
       "      <th>eventid_</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>460110413044304</td>\n",
       "      <td>2019-05-08 20:09:29</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>460110413042577</td>\n",
       "      <td>2019-05-08 20:09:41</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>460110425023300</td>\n",
       "      <td>2019-05-08 20:10:14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>460110714141865</td>\n",
       "      <td>2019-05-08 20:10:40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>DX-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>460016692088409</td>\n",
       "      <td>2019-05-08 20:08:55</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>拒绝</td>\n",
       "      <td>FDD-LTE</td>\n",
       "      <td>LT-SZSC001</td>\n",
       "      <td>Normal Lau</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             imsi_         update_time_  lac_  cellid_ status_ ap_type_  \\\n",
       "0  460110413044304  2019-05-08 20:09:29     0        0      拒绝  FDD-LTE   \n",
       "1  460110413042577  2019-05-08 20:09:41     0        0      拒绝  FDD-LTE   \n",
       "2  460110425023300  2019-05-08 20:10:14     0        0      拒绝  FDD-LTE   \n",
       "3  460110714141865  2019-05-08 20:10:40     0        0      拒绝  FDD-LTE   \n",
       "4  460016692088409  2019-05-08 20:08:55     0        0      拒绝  FDD-LTE   \n",
       "\n",
       "   device_id_    eventid_  \n",
       "0  DX-SZSC001  Normal Lau  \n",
       "1  DX-SZSC001  Normal Lau  \n",
       "2  DX-SZSC001  Normal Lau  \n",
       "3  DX-SZSC001  Normal Lau  \n",
       "4  LT-SZSC001  Normal Lau  "
      ]
     },
     "execution_count": 189,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data2.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 新入网，新离网探索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'data1' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-1-710ca0d3db0c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdata1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m: name 'data1' is not defined"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "oldHeight": 347,
   "position": {
    "height": "369px",
    "left": "930px",
    "right": "20px",
    "top": "93px",
    "width": "431px"
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "varInspector_section_display": "block",
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
